package core.service.adapter
{
import values.avatar.AvatarTemplateValueList;

/**
 * PlayerInfoDataDatapter
 * @author jliang
 *
 */
public class PlayerInfoDebugDataAdapter implements IDataAdapter
{	
	/**
	 *  
	 * return
	 * { 
	 *     tech: [ [ 科技key, 科技等级, 是否开启 ], ..... ],
	 * 		coin:xx,
	 *     cash:xx,
	 * 		wood:xx,
	 *     metal:xx,
	 *     energy: xx,
	 *     maxEnergy:xxx,
	 *     techPoint: xx,
	 *     reputation: xx,
	 *     level: xx,
	 * 		xp: xxx,
	 * 	   enhance: [ 0, 0, 0 ],    // [ 战斗强化, 特技强化, 元素强化 ]
	 *	   equipments: [  ],    // [ [ "12F0945", "equipment_1", { "level":1 } ] ]
	 * 		unlockedSlots: x,
	 *     skills: [ [ "xx1", 1 ], [ "xx2", 1 ], [ "xx5", 1 ] ],[ 技能key, 技能等级 ],.....
	 *      ultimateSkillLevel: -1 或者 1,2,3,4....
	 *      selectedSkill: 0
	 *  }
	 * 
	 */	
	public function parse(data:*):*
	{
		var result:Object = {};
		
		result.player = createAvatarData(data.player);		
		result.player.tech = data.tech;
		result.player.coin = data.coin;
		result.player.cash = data.cash;
		result.player.wood = data.wood;
		result.player.metal = data.metal;
		result.player.energy = data.energy;
		result.player.maxEnergy = data.max_energy;
		result.player.techPoint = data.tech_point;
		result.player.reputation = data.reputation;
		
		result.fight = new Vector.<Object>();
		for each (var hobj:Array in data.fight)
		{
			result.fight.push(createAvatarData(hobj));
		}
		
		result.idle = new Vector.<Object>();
		for each (var iobj:Array in data.idle)
		{
			result.idle.push(createAvatarData(iobj));
		}
		
		return result;
	}
	
	private function createAvatarData(data:Array):Object
	{
		return {
			template: AvatarTemplateValueList.getByKey(data[0]),
			level: data[1],
			xp: data[2],
			enhance: data[3],
			equipments: data[4],
			unlockedSlots: data[5],
			skills: data[6],
			ultimateSkillLevel: data[7],
			selectedSkill: data[8],
			reward:data[9]
		};
	}
}
}



